package com.zhxy.util.message;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

public class MessageCodecProtocolFactory implements ProtocolCodecFactory {
	
	private MessageCodec codec;

	public MessageCodec getCodec() {
		return codec;
	}

	public void setCodec(MessageCodec codec) {
		this.codec = codec;
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		MessageCodecEncoder encoder = new MessageCodecEncoder();
		encoder.setCodec(codec);
		return encoder;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		MessageCodecDecoder decoder = new MessageCodecDecoder();
		decoder.setCodec(codec);
		return decoder;
	}

}
